import React from 'react';
import {
    Button,
    Text,
    View,
    Image,
    StyleSheet,
    Dimensions,
    StatusBar,
    ActivityIndicator,
    FlatList,
    ScrollView,
    RefreshControl,
    Animated,
    TouchableHighlight,
    SectionList,
    TouchableOpacity,
    DeviceEventEmitter
} from 'react-native';
import { Card } from 'react-native-shadow-cards';
import QRCode from 'react-native-qrcode-svg';
import Styles from './Styles';

import app from '../../../app.json';
import Ugame from '../../../Ugame';
import Httpc from "../../utils/Httpc";
import REQUEST from "../../../REQUEST";
import styles from "../Lists/styles";

const { width, height } = Dimensions.get('window');
// 初始化总数据

export default class SafeContent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {

        };

    }
    static navigationOptions = {
        title: '安全中心',
        //header: null,  //隐藏顶部导航栏
        //tabBarVisible: false, // 隐藏底部导航栏
        headerStyle: {
            backgroundColor: '#cc0033',
            paddingTop: 18,
        },
        headerTintColor: '#fff',
        headerTitleStyle: {

        },
    }
    componentWillMount() {
        //组件将要被加载到视图之前调用
    }
    componentDidMount() {
        // 在调用了render方法，组件加载成功并被成功渲染出来之后，所要执行的后续操作，一般都会在这个函数中进行，比如经常要面对的网络请求等加载数据操作
        // *** 因为UI已经成功渲染，而且这里面是异步的，所以放在这个函数进行数据的请求等复杂的操作，不会出现UI错误**
        let navigation = this.props.navigation;
        // Ugame.isLogin(function () {
        //
        // },function () {
        //     navigation.navigate('Login')
        // })
    }
    do_quit() {
        let navigation = this.props.navigation;
        Httpc.get(REQUEST.Quit, { token: Ugame.info.Token }, function (res) {
            console.log(res);
            if (res.StatusCode != 1) {
                return;
            }

            Ugame.clearUserStorgae(function () {
                // 在登录页面,在goBack之前,将上个页面的方法取到,并回传参数,这样回传的参数会重走render方法
                //navigation.state.params.refresh();
                //navigation.goBack();
                DeviceEventEmitter.emit('updateLogin', {});
                navigation.goBack();
            });
        }.bind(this));
    }
    on_go_UserCertification() {
        if (Ugame.isLogin()) {
            this.props.navigation.navigate('UserCertification');
        } else {
            this.props.navigation.navigate('Login');
        }
    }
    on_go_SetUserPass() {
        if (Ugame.isLogin()) {
            this.props.navigation.navigate('SetUserPass');
        } else {
            this.props.navigation.navigate('Login');
        }
    }
    on_go_BindPhone = () => {
        if (Ugame.isLogin()) {
            this.props.navigation.navigate('BindPhone');
        } else {
            this.props.navigation.navigate('Login');
        }

    }
    on_go_tixianPass = () => {
        if (Ugame.isLogin()) {
            this.props.navigation.navigate('TixianPass');
        } else {
            this.props.navigation.navigate('Login');
        }

    }
    render() {
        return (
            <View style={Styles.container}>
                <StatusBar translucent={true} backgroundColor="transparent" />
                <Text style={{ color: '#6a6a6a', fontSize: 14, paddingTop: 20, paddingLeft: 10, marginBottom: 5 }}>帐号保护</Text>
                <TouchableOpacity onPress={() => this.on_go_SetUserPass()}>
                    <View style={Styles.item}>
                        <View style={styles.info}>
                            <Text style={{ fontSize: 18, color: '#333333' }}>密码修改</Text>
                            <Text style={{ fontSize: 12, color: '#969696' }}>保证帐号安全</Text>
                        </View>
                        <Image resizeMode="cover" style={styles.jt} source={require('../../image/js_img_list_jump.png')} />
                    </View>
                </TouchableOpacity>
                <TouchableOpacity onPress={() => this.on_go_UserCertification()}>
                    <View style={Styles.item}>
                        <View style={styles.info}>
                            <Text style={{ fontSize: 18, color: '#333333' }}>身份认证</Text>
                            <Text style={{ fontSize: 12, color: '#969696' }}>领奖，提款重要信息</Text>
                        </View>
                        <Image resizeMode="cover" style={Styles.jt} source={require('../../image/js_img_list_jump.png')} />
                    </View>
                </TouchableOpacity>

                {/* <TouchableOpacity onPress={() => this.on_go_BindPhone()}>
                    <View style={Styles.item}>
                        <View style={styles.info}>
                            <Text style={{ fontSize: 18, color: '#333333' }}>绑定手机号</Text>
                            <Text style={{ fontSize: 12, color: '#969696' }}>中奖消息提醒</Text>
                        </View>
                        <Image resizeMode="cover" style={Styles.jt} source={require('../../image/js_img_list_jump.png')} />
                    </View>
                </TouchableOpacity> */}
                <Text style={{ color: '#6a6a6a', fontSize: 14, paddingTop: 20, paddingLeft: 10, marginBottom: 5 }}>资金保护</Text>
                <TouchableOpacity onPress={() => this.on_go_tixianPass()}>
                    <View style={Styles.item}>
                        <View style={styles.info}>
                            <Text style={{ fontSize: 18, color: '#333333' }}>提现密码</Text>
                            <Text style={{ fontSize: 12, color: '#969696' }}>保证您资金安全</Text>
                        </View>
                        <Image resizeMode="cover" style={Styles.jt} source={require('../../image/js_img_list_jump.png')} />
                    </View>
                </TouchableOpacity>


                <TouchableOpacity onPress={() => this.do_quit()}>
                    <View style={Styles.login_btn}>
                        <Text style={{ color: '#ffffff', fontSize: 16 }}>退出登录</Text>
                    </View>
                </TouchableOpacity>

            </View>
        )
    }
}

